package API.DAY11.reflect;

import API.DAY11.reflect.annotation.AutoRunClass;
import API.DAY11.reflect.annotation.AutoRunMethod;

import java.lang.reflect.Method;

public class Test5 {
    public static void main(String[] args) throws Exception{
        Class cls = Class.forName("API.DAY11.reflect.Person");
        if (cls.isAnnotationPresent(AutoRunClass.class)) {
            Object obj = cls.newInstance();
            Method[] methods = cls.getMethods();
            for (Method method:methods){
                if(method.isAnnotationPresent(AutoRunMethod.class)){
                    AutoRunMethod arm = method.getAnnotation(AutoRunMethod.class);
                    int value = arm.value();
                    for (int i = 0; i < value; i++){
                        method.invoke(obj);
                    }
                }
            }
        } else {
            System.out.println("该类没有被标注");
        }



    }
}
